Skip to content

Conversation

@gowtham1412-p
Copy link

@gowtham1412-p gowtham1412-p commented Oct 30, 2025

Which issue does this PR close?

Closes #15774

Rationale for this change

Moving the TopK example code from the test file to user-facing documentation makes it more discoverable for users learning how to create custom operators in DataFusion.

What changes are included in this PR?

  • Added TopK operator example to extending-operators.md documentation
  • Includes logical plan node, optimizer rule, physical planner, and execution plan examples
  • Added usage instructions for implementing custom TopK queries

Are these changes tested?

Documentation-only change, no functional code changes.

Are there any user-facing changes?

Yes - users can now find the TopK custom operator example in the official documentation instead of having to browse test files.


### **2. Add a Comment on Issue #15774**

Go to https://github.com/apache/datafusion/issues/15774 and comment:

I've opened PR #18372 to address this issue. Please review at your earliest convenience.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 30, 2025
Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is completely replacing the existing contents of extending-operators.md page an intended change?

@gowtham1412-p gowtham1412-p force-pushed the doc-move-user-defined-plan branch from 8eedff8 to 55f9546 Compare October 30, 2025 11:35
@gowtham1412-p
Copy link
Author

@Jefffrey Thank you for catching that! No, completely replacing the content was not intended. I'll update the PR to preserve the existing µWheel documentation and add the TopK example as an additional section.

@gowtham1412-p
Copy link
Author

@Jefffrey I've updated the PR to preserve the existing µWheel documentation. The TopK example is now added as a second example rather than replacing the original content. Please review when you have the convienent time

plan: LogicalPlan,
_config: &dyn OptimizerConfig,
) -> Result<Transformed<LogicalPlan>> {
) -> Result<Transformed> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure this is an incorrect change --

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is the two examples on the page are incongruous. The first example is very minimal and succinct; indeed the syntax examples provided are a tiny snapshot, only showing the rewrite method in isolation of it's original trait OptimizerRule.

Meanwhile the TopK example has also minimal explanation, but all the syntax required in what seems more of a brain dump than a guide. It might be hard for people to follow what is going on since they just see a bunch of code definitions without any explanation of how they relate.

@gowtham1412-p
Copy link
Author

please review it once.

@Jefffrey
Copy link
Contributor

please review it once.

Do you have any thoughts on the comment I left above?

@gowtham1412-p
Copy link
Author

@Jefffrey Thank you for the feedback! I've restructured the TopK example to be more educational and consistent with the µWheel example. The changes include:

  • Added an Overview section explaining how the four components work together
  • Reduced code examples to only the essential parts
  • Added explanatory text between code blocks showing how they relate
  • Removed the "brain dump" feeling by focusing on the key concepts

Please let me know if this better matches the style you're looking for!

@gowtham1412-p
Copy link
Author

gowtham1412-p commented Nov 15, 2025

@Jefffrey please review it once,,,if any errors or having any concern let me know it

@Jefffrey
Copy link
Contributor

I will review this when I have time

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general layout is looking better, but there's details like syntax being incorrect which I'm quite confused by considering the example code already exists in our codebase 🤔

```rust,ignore
// Converts a uwheel aggregate result to a TableScan with a MemTable as source
fn agg_to_table_scan(result: f64, schema: SchemaRef) -> Result<LogicalPlan> {
fn agg_to_table_scan(result: f64, schema: SchemaRef) -> Result {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very confused why these changes are being made, especially considering it makes the example invalid?

Comment on lines +74 to +80
```rust,ignore
impl OptimizerRule for TopKOptimizerRule {
fn rewrite(
&self,
plan: LogicalPlan,
_config: &dyn OptimizerConfig,
) -> Result<Transformed> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to think it's better not to have the ignore as some of this syntax is not correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move code in user_defined_plan.rs to the extending-operators doc

3 participants